package cn.signalpha.modules.shop.service;

import cn.signalpha.core.tool.utils.ObjectUtil;
import cn.signalpha.modules.shop.entity.Logistics;
import cn.signalpha.modules.shop.mapper.LogisticsMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 服务类
 *
 * @author signalpha
 */
@Service
public class LogisticsService extends ServiceImpl<LogisticsMapper, Logistics> {

    /**
	 * 自定义Wrappers
	 */
    public QueryWrapper<Logistics> selectLogisticsWrapper(Map<String, Object> params) {
        QueryWrapper<Logistics> wrapper = Wrappers.query();
        wrapper.lambda().like(ObjectUtil.isNotEmpty(params.get("name")), Logistics::getName, params.get("name"));
        wrapper.lambda().like(ObjectUtil.isNotEmpty(params.get("code")), Logistics::getCode, params.get("code"));
        wrapper.lambda().like(ObjectUtil.isNotEmpty(params.get("codeWx")), Logistics::getCodeWx, params.get("codeWx"));
        wrapper.lambda().orderByDesc(Logistics::getSort).orderByDesc(Logistics::getId);
        return wrapper;
    }

}

